<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    {{-- 独立式验证 ajax --}}
    <form action="" method="post" onsubmit="return regFun()">
        <p>
            <label for="">用户名称
                {{-- 提交时有错误不会重置value值 --}}
                <input type="text" name="username" value="{{ old('username') }}">
            </label>
        </p>
        <p>
            <label for="">密码
                <input type="password" name="password" id="">
            </label>
        </p>
        <p>
            <label for="">确认密码
                <input type="password" name="password_confirmation" id="">
            </label>
        </p>
        <p>
            <label for="">邮箱
                <input type="text" name="email" id="">
            </label>
        </p>
        <p>
            <label for="">QQ
                <input type="text" name="qq" id="">
            </label>
        </p>
        <p>
            <input type="submit" value="用户注册">
        </p>
    </form>

    {{-- 独立验证返回 --}}
    <script src="https://cdn.staticfile.org/jquery/2.0.0/jquery.min.js"></script>
    <script>
        function regFun(){
            // 得到表单项值
            let frmData = $('form').serialize();
            // ajax提交
            $.post('{{route('user/req')}}',frmData).then(ret=>{
                console.log(ret);
            });
            // console.log(frmData);
            return false;
        }
    </script>
</body>
</html>